//
//  SignContractViewController.m
//  RENTVISITOR
//
//  Created by wonder on 2017/8/22.
//  Copyright © 2017年 UNN. All rights reserved.
//

#import "SignContractViewController.h"
#import "RentVieitor.h"

@interface SignContractViewController ()

@end

@implementation SignContractViewController

- (void)viewWillAppear:(BOOL)animated {
    
    [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
    self.navigationController.navigationBar.translucent = NO;
    self.navigationController.navigationBar.hidden = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"签订合同";
    [self creatLeftView];
    [self creatView];
}

- (void)creatLeftView {
    
    // 自定义导航栏左侧按钮
    UIButton * leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    leftBtn.frame = CGRectMake(0, 0, 10,15 );
    [leftBtn setBackgroundImage:[UIImage imageNamed:@"箭头左"] forState:UIControlStateNormal];
    [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem * leftItem = [[UIBarButtonItem alloc] initWithCustomView:leftBtn];
    self.navigationItem.leftBarButtonItem = leftItem;
    
    // 自定义导航栏左侧按钮
    UIButton * rightBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    rightBtn.frame = CGRectMake(0, 0, 20, 17);
    [rightBtn setBackgroundImage:[UIImage imageNamed:@"消息"] forState:UIControlStateNormal];
    [rightBtn addTarget:self action:@selector(noticeAction) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem * rightItem = [[UIBarButtonItem alloc] initWithCustomView:rightBtn];
    self.navigationItem.rightBarButtonItem = rightItem;
    
}

- (void)creatView {
    
    NSArray *imgArray = @[@"img_01",@"img_02",@"img_03"];
    NSArray *titleArray = @[@"我的租房合同",@"到期的租房合同",@"编辑租房合同"];
    NSArray *contentArray = @[@"出租人和承租人在租赁时签订的协议",@"已经到期的租房合同协议",@"编辑租赁时签订的租房协议"];
    for (int i=0; i<imgArray.count;i++ ) {
        
        UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(12.5, 10*(i+1)+100*i,KWidth-25 , 100)];
        imgView.image = [UIImage imageNamed:imgArray[i]];
        imgView.userInteractionEnabled = YES;
        imgView.tag = 100+i;
        //添加手势
        UITapGestureRecognizer * PrivateLetterTap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAvatarView:)];
        PrivateLetterTap.numberOfTouchesRequired = 1; //手指数
        PrivateLetterTap.numberOfTapsRequired = 1; //tap次数
        [imgView addGestureRecognizer:PrivateLetterTap];
        [self.view addSubview:imgView];
        
        UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(KWidth/4, 30, KWidth/4*3-20, 20)];
        textLabel.text = titleArray[i];
        textLabel.textColor = [UIColor whiteColor];
        textLabel.font = [UIFont systemFontOfSize:18];
        textLabel.textAlignment = NSTextAlignmentLeft;
        [imgView addSubview:textLabel];
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(KWidth/4, 55, KWidth/3*2-20, 20)];
        label.text = contentArray[i];
        label.textColor = [UIColor whiteColor];
        label.font = [UIFont systemFontOfSize:13];
        label.textAlignment = NSTextAlignmentLeft;
        [imgView addSubview:label];


    }
}

- (void)tapAvatarView:(UIGestureRecognizer *)recognizer {
    
    if (recognizer.view.tag == 100) {
        
        //我的
        
        
    }else if (recognizer.view.tag == 101){
        
        //到期
        
    }else if (recognizer.view.tag == 102){
        
        //编辑
        
        
    }
}

- (void)backAction {
    
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)noticeAction {
    

    
}

@end
